<?php
namespace app\common\traits;
/**
 * 数据操作基础复用
 * Class ModelCurd
 * @package app\common\traits
 */
trait ModelCurd
{
    /**
     * @Notes:创建数据
     * @User: chenping
     * @email: 375129701@qq.com
     * @param $data
     * @return mixed
     */
    public function createDatas($data)
    {
        return $this->create($data);
    }

    /**
     * @Notes:更新数据
     * @User: chenping
     * @email: 375129701@qq.com
     * @param $data
     * @return mixed
     */
    public function updateDatas($data)
    {
        return $this->update($data);
    }

    /**
     * @Notes:删除数据
     * @User: chenping
     * @email: 375129701@qq.com
     * @param $idList
     * @return mixed
     */
    public function deleteDatas($idList)
    {
        return $this->where("id","in",$idList)->delete();
    }

    /**
     * @Notes:查询全部数据
     * @User: chenping
     * @email: 375129701@qq.com
     * @return mixed
     */
    public function selectDatas()
    {
        return $this->select();
    }

    /**
     * @Notes:查询分页数据
     * @User: chenping
     * @email: 375129701@qq.com
     * @return mixed
     */
    public function selectPageDatas($page=1,$limit=20,$where=[])
    {
        return $this->where($where)->paginate($limit);
    }


    /**
     * @Notes:查找数据
     * @User: chenping
     * @email: 375129701@qq.com
     * @param $id
     * @return mixed
     */
    public function findData($id)
    {
        return $this->find($id);
    }
}